#define MYNAME "Bushnell Trail"
static gbfile *file_in;
+static gbfile *file_out;
+static int trkpt_count;
static route_head* trk_head;
static
static void
rd_deinit(void) {
- gbfclose(file_in);
+ gbfclose(file_out);
+}
+
+static void
+wr_init(const char *fname) {
+ file_out = gbfopen_le(fname, "w", MYNAME);
+ trkpt_count = 0;
+ static char obuf[20] = {"TL003"};
+ gbfwrite(&obuf, 1, 20, file_out);
+}
+
+static void
+wr_deinit(void) {
+ int i = trkpt_count;
+ while (i < 4502) {
+ gbfputint32(0, file_out);
+ gbfputint32(0, file_out);
+ i++;
+ }
+ gbfputint32(0, file_out);
+ gbfputint16(trkpt_count, file_out);
+ gbfputc(1, file_out);
+
+ gbfclose(file_out);
}
/*
}
}
+static void
+bushnell_write_one(const waypoint *wpt) {
+ trkpt_count++;
+ if (trkpt_count > 4502)
+ fatal(MYNAME " too many trackpoints. Max is 4502.");
+
+ gbint32 lat = wpt->latitude * 10000000.0;
+ gbint32 lon = wpt->longitude * 10000000.0;
+ gbfputint32(lat, file_out);
+ gbfputint32(lon, file_out);
+}
+
+static void
+bushnell_write(void) {
+ track_disp_all(NULL, NULL, bushnell_write_one);
+}
ff_vecs_t bushnell_trl_vecs = {
ff_type_file,
- { ff_cap_none, ff_cap_read, ff_cap_none },
+ { ff_cap_none, ff_cap_read | ff_cap_write, ff_cap_none },
rd_init,
- NULL,
+ wr_init,
rd_deinit,
- NULL,
+ wr_deinit,
bushnell_read,
- NULL,
+ bushnell_write,
NULL,
bushnell_args,
CET_CHARSET_MS_ANSI, 0 /* Not really sure... */
<para>
-This format supports reading tracks from
+This format supports tracks from
<ulink url="http://www.bushnell.com/products/gps/">Bushnell GPS</ulink>
receivers, notably the <productname>Onix 400</productname>.
</para>
<para>
This format reads individual .trl files as written by the GPS. As this is
a reverse-engineered format, it's not understood how long tracks, in
-particular, spam multiple files so initially this format is most effective
-on tracks under a few thousand points.
+particular, span multiple files so initially this format is most effective
+on tracks under a few thousand points.
+</para>
+<para>
+ When writing tracks, a maximum of 4502 points is supported as this is the
+ most we believe these units can represent in a track.
</para>